//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class LuminanceEffect : Effect
    {
        private double bright;

        private double contrast;

        public double Brightness
        {
            get { return bright; }
            set { bright = value; }
        }

        public double Contrast
        {
            get { return contrast; }
            set { contrast = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("lum"))
            {
                Brightness = SerializationHelper.GetOptionalPercent(c, "bright", 0);
                Contrast = SerializationHelper.GetOptionalPercent(c, "contrast", 0);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("lum"))
            {
                SerializationHelper.SetOptionalPercent(c, "bright", Brightness, 0);
                SerializationHelper.SetOptionalPercent(c, "contrast", Contrast, 0);
            }
        }
    }
}